package com.esri.core.internal.io.handler;

import com.esri.core.io.EsriSecurityException;
import java.io.IOException;
import jcifs.ntlmssp.Type1Message;
import jcifs.ntlmssp.Type2Message;
import jcifs.ntlmssp.Type3Message;
import jcifs.util.Base64;
import org.apache.http.impl.auth.NTLMEngine;
import org.apache.http.impl.auth.NTLMEngineException;

/* loaded from: classes.dex */
public class g implements NTLMEngine {
    private static final int a = -1610055676;
    private static final String b = "NTLM authentication requires a non-null domain to be specified";

    public String generateType1Msg(String str, String str2) throws NTLMEngineException {
        return Base64.encode(new Type1Message((int) a, str, str2).toByteArray());
    }

    public String generateType3Msg(String str, String str2, String str3, String str4, String str5) throws NTLMEngineException {
        if (str3 == null) {
            throw new NTLMEngineException(b, new EsriSecurityException(EsriSecurityException.NTLM_NULL_DOMAIN, b));
        }
        try {
            Type2Message type2Message = new Type2Message(Base64.decode(str5));
            return Base64.encode(new Type3Message(type2Message, str2, str3, str, str4, type2Message.getFlags() & (-196609)).toByteArray());
        } catch (IOException e) {
            throw new NTLMEngineException("Invalid NTLM type 2 message", e);
        }
    }
}
